package cn.gson.work.model.pojos;

import javax.persistence.*;
import java.util.List;
import java.util.Objects;

@Entity
public class Dept {
    private long deptNo;
    private String deptName;
    private Long inNo;
    private Long deptPhone;
    private String remarks;
    private String deptPerson;
    private List<User> users;
    private List<Volumelibrary> volumelibraries;

    @Id
    @Column(name = "DEPT_NO")
    public long getDeptNo() {
        return deptNo;
    }

    public void setDeptNo(long deptNo) {
        this.deptNo = deptNo;
    }

    @Basic
    @Column(name = "DEPT_NAME")
    public String getDeptName() {
        return deptName;
    }

    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }

    @Basic
    @Column(name = "IN_NO")
    public Long getInNo() {
        return inNo;
    }

    public void setInNo(Long inNo) {
        this.inNo = inNo;
    }

    @Basic
    @Column(name = "DEPT_PHONE")
    public Long getDeptPhone() {
        return deptPhone;
    }

    public void setDeptPhone(Long deptPhone) {
        this.deptPhone = deptPhone;
    }

    @Basic
    @Column(name = "REMARKS")
    public String getRemarks() {
        return remarks;
    }

    public void setRemarks(String remarks) {
        this.remarks = remarks;
    }

    @Basic
    @Column(name = "DEPT_PERSON")
    public String getDeptPerson() {
        return deptPerson;
    }

    public void setDeptPerson(String deptPerson) {
        this.deptPerson = deptPerson;
    }

    @OneToMany(mappedBy = "dept")
    public List<User> getUsers() {
        return users;
    }

    public void setUsers(List<User> users) {
        this.users = users;
    }

    @OneToMany(mappedBy="dept")
    public List<Volumelibrary> getVolumelibraries() {
        return volumelibraries;
    }

    public void setVolumelibraries(List<Volumelibrary> volumelibraries) {
        this.volumelibraries = volumelibraries;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Dept dept = (Dept) o;
        return deptNo == dept.deptNo &&
                Objects.equals(deptName, dept.deptName) &&
                Objects.equals(inNo, dept.inNo) &&
                Objects.equals(deptPhone, dept.deptPhone) &&
                Objects.equals(remarks, dept.remarks);
    }

    @Override
    public int hashCode() {
        return Objects.hash(deptNo, deptName, inNo, deptPhone, remarks);
    }

    @Override
    public String toString() {
        return "Dept{" +
                "deptNo=" + deptNo +
                ", deptName='" + deptName + '\'' +
                ", inNo='" + inNo + '\'' +
                ", deptPhone=" + deptPhone +
                ", remarks='" + remarks + '\'' +
                ", deptPerson='" + deptPerson + '\'' +
                ", users=" + users +
                '}';
    }
}
